<template>
  <div>
    <div class="nav">
      <hy-search
        class="search_box"
        ref="query"
        :searchTitle="searchTitle"
        v-model="searcher"
        :button="{btnShowBy3:true}"
        :buttonText="{btnNameBy3:'培训申请'}"
        :col="6"
        @search="getlist(0)"
        @clickbybtn3="add()"
      ></hy-search>
    </div>
    <!-- 筛选 --end-->
    <div id="table_box8">
      <template>
        <el-table :data="tableData" style="width: 100%" height="631" stripe>
          <el-table-column type="index" label="序号"  width="100" align="center"></el-table-column>
          <el-table-column prop="createOnStr" label="申请日期" align="center"></el-table-column>
          <el-table-column prop="theme" label="培训主题" align="center"></el-table-column>
          <el-table-column prop="time" label="培训时间" align="center"></el-table-column>
          <el-table-column prop="num" label="参与人数" align="center">
            <template slot-scope="scope">
              {{scope.row.num}}人
            </template>
          </el-table-column>
          <el-table-column prop="state" label="状态" align="center"></el-table-column>
          <el-table-column label="操作" align="center">
            <el-row slot-scope="scope">
              <!-- <el-button size="mini" type="warning" @click="Train(scope.row.trainno,1)">审核</el-button> -->
              <el-button size="mini" type="primary" @click="Train(scope.row.id)">详情</el-button>
            </el-row>
          </el-table-column>
        </el-table>
        <div class="block">
          <el-pagination
            background
            layout="prev, pager, next"
            :current-page="current"
            :page-size="pagesize"
            @current-change="handleCurrentChange"
            :total="total"
          ></el-pagination>
        </div>
      </template>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data () {
    return {
      total: 1,
      current: 1,
      pagesize: 11,     
      formInline: {},
      searchTitle: [
        {
          type: "input",
          name: "customProductName",
          label: "输入搜索",
          placeholder: "请输入培训主题",
          prop: "customProductName"
        },
        {
          type: "date2",
          name: "issuanceDate",
          label: "输入时间",
          placeholder: "请选择输入时间",
          prop: "issuanceDate"
        }
      ], 
      searcher: {
        customProductName: "",
        customProductNo: "",
        issuanceDate: ""
      },
      tableData: []
    };
  },
  created () {
    this.getlist(0);
  },
  methods: {
    // 分页
    handleCurrentChange (e) {
      this.getlist(e - 1);
    },
    //列表数据
    getlist (page) {
      let start = ""; let end = "";
      if (this.searcher.issuanceDate != null && this.searcher.issuanceDate != "") { start = this.searcher.issuanceDate[0]; end = this.searcher.issuanceDate[1]; }
      let obj = {
        creater: this.creater,
        key: this.searcher.customProductName ? this.searcher.customProductName : "",
        start: start,
        end: end,
        pn: page,
        PerPageSize: this.pagesize
      };
      var objs = JSON.stringify(obj);
      let the = { index: 10, jsondata: objs }
      // console.log(objs);
      axios.post("/apis/PersonnelMatters.asmx/GetData", the).then(({ data }) => {
        var list = eval('(' + data.d + ')');
        // console.log(list);
        this.total = list.count;
        this.tableData = list.data;
      });
    },
    //详情
    Train (e) {
      this.$router.push({
        path: "/TrainingManagementXq",
        query: { e: e }
      });
    },
    //新增
    add () {
      this.$router.push("/TrainingManagementAdd");
    }
  }
};
</script>

<style lang="scss" scoped>
@import '@/assets/scss/base.scss';
.nav {
  background: $white;
  height: 50px;
  margin-top: 10px;
  width: 98%;
  padding: 0 1%;
  .search_box {
    width: 98%;
    padding-top: 5px;
  }
}

#table_box8 {
  margin-top: 10px;
  width: 98%;
  padding: 0 1%;
  background: $white;
}
.block {
  text-align: center;
  margin-top: 10px;
}
.search_box {
  padding-top: 5px;

  width: 100%;
}
</style>
<style>
#table_box8 .el-pagination {
  text-align: center;
}
</style>